/*
 * @Author: silence
 * @Date: 2023-06-30 08:57:58
 * @LastEditors: 
 * @LastEditTime: 2023-08-17 08:54:08
 * @Description: 
 */
// /*
//  * @Author: silence
//  * @Date: 2022-07-15 17:31:51
//  * @LastEditors: Please set LastEditors
//  * @LastEditTime: 2023-08-16 20:37:23
//  * @Description: 
//  */
// import 'package:connectivity_plus/connectivity_plus.dart';

// import '../../../utils/eventBus/eventBus.dart';
// import '../../../utils/string/StringConstant.dart';

// class NetworkShareInstance {
//   // 单例公开访问点
//   factory NetworkShareInstance() => _sharedInstance();

//   // 静态私有成员，没有初始化
//   static NetworkShareInstance _instance = NetworkShareInstance._();

//   bool network = true;
//   bool isFirst = true;
//   late ConnectivityResult result;

//   // 私有构造函数
//   NetworkShareInstance._() {
//     Connectivity().checkConnectivity().then((ConnectivityResult value) {
//       result = value;
//       if (value == ConnectivityResult.none) {
//         network = false;
//       }
//     });

//     Connectivity().onConnectivityChanged.listen((ConnectivityResult event) {
//       result = event;
//       String? txt = null;
//       bool lastNetwork = network;

//       if (event == ConnectivityResult.none) {
//         network = false;
//         txt = "网络似乎断开了~";
//       } else if (event == ConnectivityResult.wifi) {
//         network = true;
//         txt = "当前处于wifi网络~";
//       } else if (event == ConnectivityResult.mobile) {
//         network = true;
//         txt = "当前处于移动网络~";
//       } else {
//         network = true;
//       }

//       if (txt != null && isFirst == false) {
//         //FLToast.text(text: txt);
//       }

//       // 如果网络状态发生变化，需要通知一下
//       if (lastNetwork != network) {
//         lastNetwork = network;
//         bus.emit(StringConstant.NetStateChange, network);
//       }

//       isFirst = false;
//     });
//   }

//   // 静态、同步、私有访问点
//   static NetworkShareInstance _sharedInstance() {
//     return _instance;
//   }
// }
